﻿using System.Drawing;
using SvgNet.SvgGdi;

namespace Graphix.Elements
{
    public class Polygon : BaseElement
    {
        #region Implementation of IElement
        private PointF[] points;

        private Pen borderColor;

        public Polygon(PointF[] points, Brush color, Pen borderColor = null)
        {
            this.Points = points;
            this.Color = color;
            this.BorderColor = borderColor;
        }

        public Polygon(PointF[] points, Pen borderColor)
            : this(points, null, borderColor)
        {

        }

        public Polygon(PointF[] points)
            : this(points, Brushes.Black, Pens.Black)
        {

        }

        public override void Draw(IGraphics graphics)
        {
            graphics.Transform = this.Transformation;
            if (this.BorderColor != null)
            {
                graphics.DrawPolygon(this.BorderColor, this.Points, this.Attributes);
            }

            if (this.Color != null)
            {
                graphics.FillPolygon(this.Color, this.Points, this.Attributes);
            }
            graphics.ResetTransform();
        }

        public Pen BorderColor
        {
            get
            {
                return this.borderColor;
            }
            set
            {
                this.borderColor = value;
            }
        }

        public PointF[] Points
        {
            get
            {
                return this.points;
            }
            set
            {
                this.points = value;
            }
        }

        #endregion
    }
}
